/*******************************************************
* Copyright (c) 2018-2088, By XuXiang all rights reserved.
*
* FileName: NetMsgLogin.cpp
* Summary: 登陆模块协议。
*
* Author: AutoBuild
* Date: --/--
*******************************************************/

#include "NetMsgLogin.h"

namespace Competition
{
	namespace Net
	{
		CSLoginRequest::CSLoginRequest() : Type(0)
		{
		}

		int CSLoginRequest::Unpack(Byte *buffer, int index)
		{
			int i = index;
			Type = DataUtil::ReadInt32(buffer, i, &i);
			DeviceID = DataUtil::ReadString(buffer, i, &i);
			return i;
		}

		//----------------------------------------

		//Empty class - CSQuitRequest

		//----------------------------------------

		SCLoginResponse::SCLoginResponse() : Result(0), UserID(0), LastLogin(0), LastQuit(0)
		{
		}

		int SCLoginResponse::Pack(Byte *buffer, int index)
		{
			int i = index;
			i = DataUtil::WriteInt32(buffer, i, Result);
			i = DataUtil::WriteInt32(buffer, i, UserID);
			i = DataUtil::WriteString(buffer, i, NickName);
			i = DataUtil::WriteInt64(buffer, i, LastLogin);
			i = DataUtil::WriteInt64(buffer, i, LastQuit);
			return i;
		}

		//----------------------------------------

		//Empty class - SCQuitResponse

		//----------------------------------------

		SDGetUserRequest::SDGetUserRequest() : UID(0), Type(0)
		{
		}

		int SDGetUserRequest::Unpack(Byte *buffer, int index)
		{
			int i = index;
			UID = DataUtil::ReadInt64(buffer, i, &i);
			Type = DataUtil::ReadInt32(buffer, i, &i);
			DeviceID = DataUtil::ReadString(buffer, i, &i);
			return i;
		}

		int SDGetUserRequest::Pack(Byte *buffer, int index)
		{
			int i = index;
			i = DataUtil::WriteInt64(buffer, i, UID);
			i = DataUtil::WriteInt32(buffer, i, Type);
			i = DataUtil::WriteString(buffer, i, DeviceID);
			return i;
		}

		//----------------------------------------

		DSGetUserResponse::DSGetUserResponse() : UID(0), Type(0), UserID(0), CreateTime(0), LastLogin(0), LastQuit(0)
		{
		}

		int DSGetUserResponse::Unpack(Byte *buffer, int index)
		{
			int i = index;
			UID = DataUtil::ReadInt64(buffer, i, &i);
			Type = DataUtil::ReadInt32(buffer, i, &i);
			DeviceID = DataUtil::ReadString(buffer, i, &i);
			UserID = DataUtil::ReadInt32(buffer, i, &i);
			NickName = DataUtil::ReadString(buffer, i, &i);
			CreateTime = DataUtil::ReadInt64(buffer, i, &i);
			LastLogin = DataUtil::ReadInt64(buffer, i, &i);
			LastQuit = DataUtil::ReadInt64(buffer, i, &i);
			return i;
		}

		int DSGetUserResponse::Pack(Byte *buffer, int index)
		{
			int i = index;
			i = DataUtil::WriteInt64(buffer, i, UID);
			i = DataUtil::WriteInt32(buffer, i, Type);
			i = DataUtil::WriteString(buffer, i, DeviceID);
			i = DataUtil::WriteInt32(buffer, i, UserID);
			i = DataUtil::WriteString(buffer, i, NickName);
			i = DataUtil::WriteInt64(buffer, i, CreateTime);
			i = DataUtil::WriteInt64(buffer, i, LastLogin);
			i = DataUtil::WriteInt64(buffer, i, LastQuit);
			return i;
		}

		//----------------------------------------

		SDAddUserRequest::SDAddUserRequest() : UserID(0), Type(0), CreateTime(0)
		{
		}

		int SDAddUserRequest::Unpack(Byte *buffer, int index)
		{
			int i = index;
			UserID = DataUtil::ReadInt32(buffer, i, &i);
			Type = DataUtil::ReadInt32(buffer, i, &i);
			DeviceID = DataUtil::ReadString(buffer, i, &i);
			NickName = DataUtil::ReadString(buffer, i, &i);
			CreateTime = DataUtil::ReadInt64(buffer, i, &i);
			return i;
		}

		int SDAddUserRequest::Pack(Byte *buffer, int index)
		{
			int i = index;
			i = DataUtil::WriteInt32(buffer, i, UserID);
			i = DataUtil::WriteInt32(buffer, i, Type);
			i = DataUtil::WriteString(buffer, i, DeviceID);
			i = DataUtil::WriteString(buffer, i, NickName);
			i = DataUtil::WriteInt64(buffer, i, CreateTime);
			return i;
		}

		//----------------------------------------

		SDUpdateUserTimeRequest::SDUpdateUserTimeRequest() : UserID(0), LastLogin(0), LastQuit(0)
		{
		}

		int SDUpdateUserTimeRequest::Unpack(Byte *buffer, int index)
		{
			int i = index;
			UserID = DataUtil::ReadInt32(buffer, i, &i);
			LastLogin = DataUtil::ReadInt64(buffer, i, &i);
			LastQuit = DataUtil::ReadInt64(buffer, i, &i);
			return i;
		}

		int SDUpdateUserTimeRequest::Pack(Byte *buffer, int index)
		{
			int i = index;
			i = DataUtil::WriteInt32(buffer, i, UserID);
			i = DataUtil::WriteInt64(buffer, i, LastLogin);
			i = DataUtil::WriteInt64(buffer, i, LastQuit);
			return i;
		}
	}
}
